package com.example.aigc_education.validation;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.*;

@Documented
@Constraint(validatedBy = {EnumValidator.class})
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR, ElementType.PARAMETER })
@Retention(RetentionPolicy.RUNTIME)
public @interface EnumValid {

    /**
     * 不合法时 抛出异常信息
     */
    String message() default "值不合法";

    /**
     * 校验的枚举类
     * @return
     */
    Class enumClass() default Enum.class;

    /**
     * 对应枚举类中需要比对的字段
     * @return
     */
    String field() default "value";

    Class<?>[] groups() default { };

    Class<? extends Payload>[] payload() default { };
}